#include <SFML\Graphics.hpp>

#include <vector>
#include "World.h"
#include "MenuElements.h"
#include "ClickableArea.h"


int main() {
	//Here is where we create the main loop
	sf::RenderWindow window(sf::VideoMode(800,600), "PixelRunner Platformer"); //We reference gwindow as our main game window
	window.setFramerateLimit(60);
	
	std::vector<ClickableArea*> menuElements;
	menuElements.push_back(new StartButton(sf::Vector2i(100, 100), sf::Vector2i(250, 150)));

	//Demo test of tile
	
	

	while(window.isOpen()) 
	{
		sf::Event event; //check window events
		while (window.pollEvent(event))
		{
			switch (event.type){

				case sf::Event::Closed:
					window.close();
					break;

					case sf::Event::MouseButtonPressed:
                    if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
                    {
                        //Check if you clicked to any areas that have on click effect.
                        for(auto& onclickObj : menuElements)
                        {
                            if(onclickObj->processMouseEvent( sf::Mouse::getPosition(window) , window)); //Note: It also call onclickObj->doSomething()
                        }
						break;
					}

				default:
				break;
			}
		}
		window.clear(sf::Color(0,0,0));

		//Draws
        for(auto& onclickObj : menuElements)
            window.draw(*onclickObj);
		
		window.display();
	}
	for(auto& onclickObj : menuElements)
		delete onclickObj;
}